package org.example.pojo;

import lombok.Data;

@Data
public class Result<T> 
{
	private Integer code;
	private String mes;
	private T data;

	public Result(Integer code, String mes) {
		this.code = code;
		this.mes = mes;
	}

	public Result(Integer code, String mes, T data) {
		this.code = code;
		this.mes = mes;
		this.data = data;
	}

	public static <T> Result<T> ok()
	{
		return new Result<T>(200,"ok");
	}

	public static <T> Result<T> ok(String mes)
	{
		return new Result<T>(200,mes);
	}

	public static <T> Result<T> ok(String mes,T data)
	{
		return new Result<T>(200,mes,data);
	}

	public static <T> Result<T> ok(T data)
	{
		return new Result<T>(200,"ok",data);
	}
	
	public static <T> Result<T> error()
	{
		return new Result<>(500,"error");
	}

	public static <T> Result<T> error(String mes)
	{
		return new Result<T>(200,mes);
	}
}
